/* jshint esversion:6 */

/**
 * @author: errorcpp@qq.com
 */

var xwindow = ("undefined" != typeof(window)) ? window : global;
xwindow.xlib = xwindow.xlib || {};
let xlib = xwindow.xlib;

/**
 * @brief: 模拟的int64实际取值范围是-(2^53) <= N <= 2^53
 */
xlib.Int64 = function (high, low) {
    if(low === void 0) { 
        low = 0; 
    }

    if(high === void 0) {
        high = 0;
    }

    this._low  = low;
    this._high = high;
};

xlib.Int64.prototype.value = function () {
    let _h  = this._high.toString(16);
    let _hd = 8 - _h.length;
    if(_hd > 0) {
        for(let n = 0; n < _hd; ++n) {
            _h = '0' + _h;
        }
    }

    let _l  = this._low.toString(16);
    let _ld = 8 - _l.length;
    if(_ld > 0) {
        for(let n = 0; n < _ld; ++n) {
            _l = '0' + _l;
        }
    }

    //this._value = Number('0x' + _h + _l);

    return this._value;
};

xlib.Int64.MAX_VALUE = Math.pow(2,  53);
xlib.Int64.MIN_VALUE = Math.pow(-2, 53);

xlib.Int64.UintTest = function() {
    let n = new xlib.Int64(-1, 0xffffffff);
    //console.log(n);
    //console.log(n.value());
    
};

if(xlib.__enable_auto_unit_test)
    xlib.Int64.UintTest();
